/*
**    Copyright (C) 2003-2011 Institute for Systems Biology
**                            Seattle, Washington, USA.
**
**    This library is free software; you can redistribute it and/or
**    modify it under the terms of the GNU Lesser General Public
**    License as published by the Free Software Foundation; either
**    version 3 of the License, or (at your option) any later version.
**
**    This library is distributed in the hope that it will be useful,
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
**    Lesser General Public License for more details.
**
**    You should have received a copy of the GNU Lesser General Public
**    License along with this library; if not, write to the Free Software
**    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

package org.systemsbiology.util;

/**
 * An interface for adding up a sequence of Double values. This is to allow a variety of
 * approaches to be used to make appropriate time/space/accuracy tradeoffs to deal with
 * double precision error, because there are many approaches far better than naive
 * totalling.
 *
 * Summator is defined in this way to make use of primitive typing without regard to
 * other approaches to summation. For example, summation of long values through this
 * interface would require a conversion to double to make use of the {@link #add} method.
 * This interface also fails to support summation of dynamic objects; for this, use
 * {@link ComplexSummator}. 
 * 
 * It is recommended that total() be called as infrequently and as late as possible.
 * Many algorithms wil only work correctly if they have the entire data set to
 * work from, and total() may be a destructive operation relative to rounded-off
 * double truncation.
 * 
 * @author anorberg
 *
 */
public interface Summator {

	public void add(double d);

	public double total();

	public void clear();

}
